package com.battle.service.controller.web;

import com.battle.pojo.param.trainingUser.*;
import com.battle.pojo.vo.trainingUser.*;
import com.battle.service.service.in.*;
import nirvana.core.domains.vo.PageResult;
import nirvana.core.domains.vo.ApiResult;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

import java.util.List;

/**
 * web/我的训练记录
 * 【描 述】：
 * 【环 境】：J2SE
 * 【详 细】：
 */
@RestController
@RequestMapping("/trainingUser/web")
public class TrainingUserWebController {

    private final TrainingUserService service;

    public TrainingUserWebController(TrainingUserService service) {
        this.service = service;
    }


    /**
     * 创建我的训练记录
     *
     * @param param
     * @return
     */
    @PostMapping("/createTrainingUser")
    public ApiResult createTrainingUser(@RequestBody @Valid CreateTrainingUserParam param) {
        service.createTrainingUser(param);
        return ApiResult.ok();
    }


    /**
     * 修改我的训练记录
     *
     * @param param
     */
    @PutMapping("/editTrainingUser")
    public ApiResult editTrainingUser(@RequestBody @Valid EditTrainingUserParam param) {
        service.editTrainingUser(param);
        return ApiResult.ok();
    }

    /**
     * 获取我的训练记录详情
     *
     * @param id
     * @return
     */
    @GetMapping("/getTrainingUser")
    public ApiResult<GetTrainingUserVo> getTrainingUser(@RequestParam("id") Long id) {
        GetTrainingUserVo vo = service.getTrainingUser(id);
        return ApiResult.ok(vo);
    }

    /**
     * 获取我的训练记录列表
     *
     * @param param
     * @return
     */
    @PostMapping("/getTrainingUserList")
    public ApiResult<PageResult<GetTrainingUserListVo>> getTrainingUserList(@RequestBody GetTrainingUserListParam param) {
        PageResult<GetTrainingUserListVo> result = service.getTrainingUserList(param);
        return ApiResult.ok(result);
    }


}

